(function($){
	$.fn.extend({
		checkSelect : function(allButtonClassName, boldable) {			
			if (boldable==null) boldable = false;
			
			this.attr("style","cursor:hand");
			this.next().attr("style","cursor:hand");
			
			var me = this;
			this.each(function(n){
				this.onclick = function(event){
					if ($(me[n]).attr("checked")) {
						if (boldable) {
							$(me[n]).next().addClass("boldFont");
						}
					}else{
						if (boldable) {
							$(me[n]).next().removeClass("boldFont");
						}
						if (allButtonClassName!=null) {
							if ($("."+allButtonClassName).is(":checked")) {
								$("."+allButtonClassName).attr("checked","");
								if (boldable) {
									$("."+allButtonClassName).next().removeClass("boldFont");
								}
							}
						}
					}					
				};
			});
			
			var current = $(this);
			
			current.next().each(function(n){				
				this.onclick = function(event){
					if($(current[n]).is(":checked")) {
						$(current[n]).attr("checked","");		
						if (allButtonClassName!=null) {
							if ($("."+allButtonClassName).is(":checked")) {
								$("."+allButtonClassName).attr("checked","");	
								if (boldable) {
									$("."+allButtonClassName).next().removeClass("boldFont");
								}
							}
						}
					}else{
						$(current[n]).attr("checked","checked");						
					}
					if (boldable) {
						$(this).toggleClass("boldFont");
					}
				};
			});

		} , checkAll : function(buttonClassName,boldable) {	
			if (boldable==null) boldable = false;
			
			this.bind( "click" ,function(event){
				var current = $(this);
				if (current.is(":checked")) {
					$("."+buttonClassName).attr("checked","checked");
					if (boldable) {
						$("."+buttonClassName).next().addClass("boldFont");
					}
				}else{
					$("."+buttonClassName).attr("checked","");
					if (boldable) {
						$("."+buttonClassName).next().removeClass("boldFont");
					}
				}
			});
			var outer = this;
			this.next().bind("click" ,function(event){				
				var current = $(this);
				if (outer.is(":checked")) {
					$("."+buttonClassName).attr("checked","checked");
					if (boldable) {
						$("."+buttonClassName).next().addClass("boldFont");
					}
				}else{
					$("."+buttonClassName).attr("checked","");
					if (boldable) {
						$("."+buttonClassName).next().removeClass("boldFont");
					}
				}
			});
		}
	});
})(jQuery);